<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>05-个人中心-已登录-01设置-03手机号</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Pragma" content="no-cache">
    <link href="css/public.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/personal.css" rel="stylesheet" type="text/css" media="all" />
    <script src="js/jquery-2.1.4.min.js"></script>
</head>
<body class="graybody">
<header class="header">
    <div class="header_right"><a href="#" class="fontcolor">保存</a></div>
    <div class="header_left"><a href="#" class="returnico"></a></div>
    <div class="header_center fontcolor">手机号</div>
</header>
<div class="changename">
    <input type="tel" class="changenameinput" placeholder="请输入您的手机号" id="phone" maxlength="11">
    <input type="text" class="changetext" placeholder="请输入验证码"><input type="button" class="changeyzm" value="获取验证码" id="yzmInput" >
</div>
<script>
    //手机格式验证
    function chkPhone(){
        var phone=$("#phone").val();
        var patternPhone=/^1[3|4|5|7|8][0-9]\d{8}$/;
        if(patternPhone.test(phone)){
			showtime(60);
        }else{
			alert("您输入的手机格式有误！")
            return false;
        }
    }
    //验证码
	var phone_b=document.getElementById("yzmInput");
	function showtime(t){
		phone_b.disabled=true; //按钮不可用
		for(i=1;i<=t;i++) {
			window.setTimeout("update_p(" +i+ "," +t+ ")", i * 1000);
		}
	}
	function update_p(num,t) {
		 if(num == t){
			 phone_b.value =" 重新发送 ";
			 phone_b.disabled=false; //按纽可用
			 $(".changeyzm").removeClass("indexbgcolor");
		 }
		 else{
			 printnr = t-num;
			 phone_b.value="重新发送(" + printnr +")";
			 $(".changeyzm").addClass("indexbgcolor");
		 }
	}
 	$("#yzmInput").click(function(){
		chkPhone();
	})
</script>
</body>
</html>